package TagRate.project.client;

import TagRate.project.pages.client.AboutPage;
import TagRate.project.pages.client.ConfigPage;
import TagRate.project.pages.client.ConfigTestPage;
import TagRate.project.pages.client.MainPage;

import com.google.gwt.core.client.GWT;
import com.web_bloks.content.client.ContentPage;
import com.web_bloks.content.client.ContentPages;
import com.web_bloks.system.client.Logger;

/**
 * 
 * @author Jean-Lou Dupont
 *
 */
public class PageManager {

	/**
	 * Add application pages here
	 * @author Jean-Lou Dupont
	 *
	 */
	final static class PagesList extends ContentPages {
		
		protected void initList() {
			Logger.logDebug(this.getClass()+".initList");
			
			add( (ContentPage) GWT.create(MainPage.class) );
			add( (ContentPage) GWT.create(AboutPage.class) );
			add( (ContentPage) GWT.create(ConfigPage.class) );
			add( (ContentPage) GWT.create(ConfigTestPage.class) );
		}
	}
	
	
	static PagesList pl = null;
	
	public PageManager() {
		if (null==pl) {
			pl = GWT.create(PagesList.class);
			pl.initList();
		}
	}
	
	public ContentPage getContentPage(String pageName) {
		
		Logger.logInfo(this.getClass()+".getContentPage: pageName["+pageName+"]");
		
		if (null==pageName || pageName.length()==0)
			return null;
			
		ContentPage cp = pl.get(pageName);
		
		Logger.logInfo(this.getClass()+".getContentPage: cp.getPageName["+cp.getPageName()+"]");
		
		return cp;
	}
	
}
